#version 460
#extension GL_GOOGLE_include_directive : enable
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require

#include "../../../../core/shader_std.h"
#include "../../../../core/shader_curve.h"



layout(points) in;
layout(line_strip, max_vertices=32) out;


layout(std140, binding = DEF_BINDING_PROJECT) uniform U_Matrix0 {
	mat4 mat_ProjecView;
};


layout(location = 1) in VS_GS_VERTEX {
	vec4 vColor;
	vec2 vPosA;
	vec2 vPosB;
}vertex_in[];


layout(location = 0) out vec4 gColor;
out gl_PerVertex {
	vec4	gl_Position;
};

//vec2 pos[4] = {vec2(10.0, 10.0), vec2(100.0, 10.0), vec2(10.0, 100.0), vec2(100.0, 100.0)};

void main(void){
	S_CurvePoint2 s_curve, e_curve;

	s_curve.value = vertex_in[0].vPosA;
	e_curve.value = vertex_in[0].vPosB;

	float c = (e_curve.value.x - s_curve.value.x) * 0.4;
	if (c >= 1 && false) {
		s_curve.R_point = vec2(s_curve.value.x + c, s_curve.value.y);
		e_curve.L_point = vec2(e_curve.value.x - c, e_curve.value.y);
		
		int num = 16;
		float mixCoord = 1.0/num;
		for(uint i=0; i<num; ++i){
			vec4 vert = vec4(f_curve_cal_point(s_curve, e_curve, (i*mixCoord)), 0, 1);
			
			gl_Position = mat_ProjecView * vert;
			gColor = vertex_in[0].vColor;
			EmitVertex();
		}
	}
	else {
		gl_Position = mat_ProjecView * vec4(vertex_in[0].vPosA, 0, 1);
		gColor = vertex_in[0].vColor;
		EmitVertex();

		gl_Position = mat_ProjecView * vec4(vertex_in[0].vPosB, 0, 1);
		gColor = vertex_in[0].vColor;
		EmitVertex();
	}
	
	EndPrimitive();
}



 